
// Open MoneySpinner Suite v1
// An open source business management software system written in Java and MySQL
// Recommended IDE is NetBeans IDE 7.0.1
// Support Web Site: http://www.milliscript.com
//
// Copyright (C) 2014, Abiodun Aremu, Ibadan/NIGERIA.
// Open MoneySpinner Suite is distributed under the terms of the Apache License version 2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package openmoneyspinnersuite;

/**
 *
 * @author Abiodun Aremu
 */
import javax.swing.*;
import java.text.*;


final class ViewInvoice extends javax.swing.JInternalFrame {
    
    Object[][] tableObject=new Object[][]{};
    Systems systems=new Systems();
    String creditBy;
    String creditByID;
    String orderBy;
    String orderByID;
    String consentBy;
    String consentByID;
    String accountCode;
    String accountUnit;
    String accountName;
    String creditCode;
    String discount;
    String refDepartmentCode;
    String postDate;
    String orderDate;
    String totalAmount;
    String amountInWords;
    String paidAmount;
    String amtDue;
    String[] dbSerial;
    String[] dbItem;
    String[] dbDescription;
    String[] dbAmount;
    String transactionType;
    String transactionTypeCode;
    String transactionNumber;
    String transactionDate;
    String[] dbCreditCode;
    String[] dbCreditDate;
    DateFormat dateFormat=DateFormat.getDateInstance(DateFormat.LONG);
    Thread processThread=new Thread();
    Thread titleThread=new Thread();

        //PDDocument doc = null;
    /** Creates new form ViewPendingCreditOrder */
    ViewInvoice() {
        initComponents();
        setTitle("::. View Invoice Order");
        resetOrderCode();
        resetTable();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jNameTextField = new javax.swing.JTextField();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTotAmountTextField = new javax.swing.JTextField();
        jOrderDateTextField = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jPreviewButton = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jRefDepartmentTextField = new javax.swing.JTextField();
        jTransactionTypeTextField = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jTransactionNumberTextField = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTransactionDateTextField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jAccountNameTextField = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTransactionUnitTextField = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jLabel14 = new javax.swing.JLabel();
        jNetAmtTextField = new javax.swing.JTextField();
        jPaidTextField = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jCancelButton = new javax.swing.JButton();
        jCheckBox5 = new javax.swing.JCheckBox();
        jLabel9 = new javax.swing.JLabel();
        jDiscountTextField = new javax.swing.JTextField();
        jCheckBox6 = new javax.swing.JCheckBox();
        jLabel16 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jAmountInWordsTextArea = new javax.swing.JTextArea();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setResizable(true);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(openmoneyspinnersuite.OpenMS_Finance_App.class).getContext().getResourceMap(ViewInvoice.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
        setName("Form"); // NOI18N
        setVisible(true);

        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jNameTextField.setEditable(false);
        jNameTextField.setName("jNameTextField"); // NOI18N
        jNameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNameTextFieldActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Select --" }));
        jComboBox1.setName("jComboBox1"); // NOI18N
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        jLabel2.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jTotAmountTextField.setEditable(false);
        jTotAmountTextField.setName("jTotAmountTextField"); // NOI18N
        jTotAmountTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTotAmountTextFieldActionPerformed(evt);
            }
        });

        jOrderDateTextField.setEditable(false);
        jOrderDateTextField.setName("jOrderDateTextField"); // NOI18N
        jOrderDateTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jOrderDateTextFieldActionPerformed(evt);
            }
        });

        jLabel5.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jPreviewButton.setText(resourceMap.getString("jPreviewButton.text")); // NOI18N
        jPreviewButton.setName("jPreviewButton"); // NOI18N
        jPreviewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPreviewButtonActionPerformed(evt);
            }
        });

        jLabel3.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jRefDepartmentTextField.setEditable(false);
        jRefDepartmentTextField.setName("jRefDepartmentTextField"); // NOI18N
        jRefDepartmentTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRefDepartmentTextFieldActionPerformed(evt);
            }
        });

        jTransactionTypeTextField.setEditable(false);
        jTransactionTypeTextField.setName("jTransactionTypeTextField"); // NOI18N
        jTransactionTypeTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTransactionTypeTextFieldActionPerformed(evt);
            }
        });

        jLabel6.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jTransactionNumberTextField.setEditable(false);
        jTransactionNumberTextField.setName("jTransactionNumberTextField"); // NOI18N
        jTransactionNumberTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTransactionNumberTextFieldActionPerformed(evt);
            }
        });

        jLabel7.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jTransactionDateTextField.setEditable(false);
        jTransactionDateTextField.setName("jTransactionDateTextField"); // NOI18N
        jTransactionDateTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTransactionDateTextFieldActionPerformed(evt);
            }
        });

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jAccountNameTextField.setEditable(false);
        jAccountNameTextField.setName("jAccountNameTextField"); // NOI18N
        jAccountNameTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jAccountNameTextFieldActionPerformed(evt);
            }
        });

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jTransactionUnitTextField.setEditable(false);
        jTransactionUnitTextField.setName("jTransactionUnitTextField"); // NOI18N
        jTransactionUnitTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTransactionUnitTextFieldActionPerformed(evt);
            }
        });

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jLabel12.setFont(resourceMap.getFont("jLabel12.font")); // NOI18N
        jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
        jLabel12.setName("jLabel12"); // NOI18N

        jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N
        jCheckBox1.setName("jCheckBox1"); // NOI18N

        jCheckBox2.setText(resourceMap.getString("jCheckBox2.text")); // NOI18N
        jCheckBox2.setName("jCheckBox2"); // NOI18N

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        jNetAmtTextField.setEditable(false);
        jNetAmtTextField.setName("jNetAmtTextField"); // NOI18N
        jNetAmtTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jNetAmtTextFieldActionPerformed(evt);
            }
        });

        jPaidTextField.setEditable(false);
        jPaidTextField.setName("jPaidTextField"); // NOI18N
        jPaidTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPaidTextFieldActionPerformed(evt);
            }
        });

        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jCancelButton.setIcon(resourceMap.getIcon("jCancelButton.icon")); // NOI18N
        jCancelButton.setText(resourceMap.getString("jCancelButton.text")); // NOI18N
        jCancelButton.setName("jCancelButton"); // NOI18N
        jCancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCancelButtonActionPerformed(evt);
            }
        });

        jCheckBox5.setText(resourceMap.getString("jCheckBox5.text")); // NOI18N
        jCheckBox5.setName("jCheckBox5"); // NOI18N
        jCheckBox5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox5ActionPerformed(evt);
            }
        });

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jDiscountTextField.setEditable(false);
        jDiscountTextField.setName("jDiscountTextField"); // NOI18N
        jDiscountTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jDiscountTextFieldActionPerformed(evt);
            }
        });

        jCheckBox6.setText(resourceMap.getString("jCheckBox6.text")); // NOI18N
        jCheckBox6.setName("jCheckBox6"); // NOI18N
        jCheckBox6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox6ActionPerformed(evt);
            }
        });

        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jAmountInWordsTextArea.setColumns(20);
        jAmountInWordsTextArea.setEditable(false);
        jAmountInWordsTextArea.setLineWrap(true);
        jAmountInWordsTextArea.setRows(5);
        jAmountInWordsTextArea.setEnabled(false);
        jAmountInWordsTextArea.setName("jAmountInWordsTextArea"); // NOI18N
        jScrollPane2.setViewportView(jAmountInWordsTextArea);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(35, 35, 35))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jNetAmtTextField)
                            .addComponent(jTotAmountTextField)
                            .addComponent(jTransactionUnitTextField)
                            .addComponent(jTransactionDateTextField)
                            .addComponent(jTransactionNumberTextField)
                            .addComponent(jTransactionTypeTextField)
                            .addComponent(jNameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                            .addComponent(jPaidTextField))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(66, 66, 66)
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel3)
                                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(jLabel5)
                                                .addComponent(jLabel9))
                                            .addGap(18, 18, 18))
                                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabel16)
                                            .addGap(3, 3, 3)))
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jRefDepartmentTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                                        .addComponent(jAccountNameTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                                        .addComponent(jOrderDateTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                                        .addComponent(jDiscountTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jPreviewButton)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jCheckBox6)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jCheckBox1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jCheckBox2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jCheckBox5)))))
                        .addGap(18, 18, 18))
                    .addComponent(jLabel12))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(222, 222, 222)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel15)
                            .addComponent(jPaidTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jAccountNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel4)
                                    .addComponent(jNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel6)
                                    .addComponent(jTransactionTypeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel7)
                                    .addComponent(jTransactionNumberTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jTransactionDateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel16))
                                .addGap(9, 9, 9)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel11)
                                    .addComponent(jTransactionUnitTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jRefDepartmentTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jOrderDateTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jDiscountTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jTotAmountTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel14)
                                    .addComponent(jNetAmtTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(6, 6, 6))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jCheckBox6, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jCheckBox2)
                                    .addComponent(jCheckBox5))
                                .addGap(7, 7, 7)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                .addComponent(jLabel12))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(116, 116, 116)
                .addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)
                .addGap(48, 48, 48)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jPreviewButton, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "S/N", "Item", "Description", "Amount"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(10);
        jTable1.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("jTable1.columnModel.title0")); // NOI18N
        jTable1.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("jTable1.columnModel.title3")); // NOI18N
        jTable1.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("jTable1.columnModel.title4")); // NOI18N
        jTable1.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("jTable1.columnModel.title5")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1000, Short.MAX_VALUE)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNameTextFieldActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jNameTextFieldActionPerformed

    private void jTotAmountTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTotAmountTextFieldActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jTotAmountTextFieldActionPerformed

    private void jOrderDateTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jOrderDateTextFieldActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jOrderDateTextFieldActionPerformed

    private void jPreviewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPreviewButtonActionPerformed
        
        /* Execute thread */
        processThread=new Thread(new Runnable() {
            public void run() {
            disableControls();
            previewDoc();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewItemThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }//GEN-LAST:event_jPreviewButtonActionPerformed

    void previewDoc()
    {
        
        String transferState="";
        int quantity=1;
//        PDDocument doc = null;
//        try{
//          /* Step 1: Prepare the document.
//           */
//         doc = new PDDocument();
//         PDPage page = new PDPage();
//         doc.addPage(page);
//            PDFont font = PDType1Font.HELVETICA_BOLD;
//            
//                    PDXObjectImage image = null;
//         image = new PDJpeg(doc, new FileInputStream("C:\\profile_head01.jpg"));
//           PDPageContentStream content = new PDPageContentStream(doc, page);
//         content.drawImage(image,20,20);
//           content.beginText();
//           content.setFont( font, 12 );
//           
//               content.moveTextPositionByAmount( 100, 700 );
//               content.drawString("100,700 &lt; html &gt; &lt; b &gt; Hello world &lt; /b &gt; from www.printmyfolders.com &lt; /html &gt;");
//           content.endText();
//           content.beginText();
//           content.setFont( font, 12 );           
//               content.moveTextPositionByAmount( 100, 300 );
//               content.drawString("100,300 &lt; html &gt; &lt; b &gt; Hello world &lt; /b &gt; from www.printmyfolders.com &lt; /html &gt;");
//           content.endText();
//           content.beginText();
//           content.setFont( font, 12 );           
//               content.moveTextPositionByAmount( 500, 400 );
//               content.drawString("500,400&lt; html &gt; &lt; b &gt; Hello world &lt; /b &gt; from www.printmyfolders.com &lt; /html &gt;");
//           content.endText();
//           content.beginText();
//           content.setFont( font, 12 );           
//               content.moveTextPositionByAmount( 700, 400 );
//               content.drawString("700,400 &lt; html &gt; &lt; b &gt; Hello world &lt; /b &gt; from www.printmyfolders.com &lt; /html &gt;");
//           content.endText();
//           content.beginText();
//           content.setFont( font, 12 );           
//               content.moveTextPositionByAmount( 800, 900 );
//               content.drawString("800,900 &lt; html &gt; &lt; b &gt; Hello world &lt; /b &gt; from www.printmyfolders.com &lt; /html &gt;");
//           content.endText();
//           
////           for(int x=0;x<200;x++){
////               content.moveTextPositionByAmount( 100, 700+x );
////               content.drawString("&lt; html &gt; &lt; b &gt; Hello &lt; /b &gt; from www.printmyfolders.com &lt; /html &gt;");
////           }
//           
//           content.close();
//        
//         PDPage page1 = new PDPage();
//         doc.addPage(page1);
//                    PDXObjectImage image1 = null;
//         image = new PDJpeg(doc, new FileInputStream("C:\\profile_head01.jpg"));
//           PDPageContentStream content1 = new PDPageContentStream(doc, page1);
//         content1.drawImage(image,20,600);
//           content1.close();
//        doc.save("C:\\HTMLNowPdf1.pdf"); 
//        
//        
//        NoteWriter note=new NoteWriter();
//        note.writeReceipt("CO0000002",transferState,quantity);
//        // step 1
//        Document document = new Document();
//        // step 2
//        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("C:\\itx_pdf.pdf"));
//        // step 3
//        document.open();
//        // step 4
//        XMLWorkerHelper.getInstance().parseXHtml(writer, document,
//                new FileInputStream(Configuration.officialReceiptPath));
//        //step 5
//         document.close();
//        //doc.print();
//        } catch (Exception e){
//             System.out.println("Exception inView"+e);
//        }
       if(jComboBox1.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select a Order Code ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
//        javax.swing.JInternalFrame printReceipt=new PrintReceipt(String.valueOf(jComboBox1.getSelectedItem()).trim());
//        this.getDesktopPane().add(printReceipt);
//        this.getDesktopPane().moveToFront(printReceipt);
        //java.lang.Runtime run=java.lang.Runtime.getRuntime();
        //java.lang.Runtime runAgain=java.lang.Runtime.getRuntime();
       if(jCheckBox6.isSelected())
       {
           Configuration.officialInvoiceFooterImagePath=Configuration.officialSignedInvoiceFooterImagePath;
           Configuration.officialInvoiceFooterImageURLPath=Configuration.officialSignedInvoiceFooterImageURLPath;
       }
       else{
           Configuration.officialInvoiceFooterImagePath=Configuration.officialInvoiceFooterImagePath2;
           Configuration.officialInvoiceFooterImageURLPath=Configuration.officialInvoiceFooterImageURLPath2;
       }
        if(jCheckBox5.isSelected())
        {
            boolean found=false;
            javax.swing.JInternalFrame allIntFr[]=this.getDesktopPane().getAllFrames();
            for(JInternalFrame iFr:allIntFr)
            {
                if(iFr.getTitle().equalsIgnoreCase("::. Preview POS Receipt"))
                {
                    ((POSPrint)iFr).setInvoiceValue(jComboBox1.getSelectedItem().toString());
                    found=true;
                }
            }
            if(found==false)
                this.getDesktopPane().add(new POSPrint(jComboBox1.getSelectedItem().toString()));
            return;
        }
        try
        {
            NoteWriter note=new NoteWriter();
            note.writeInvoice(jComboBox1.getSelectedItem().toString(),transferState,quantity);
                       
            if(OpenMSApp.d==null)
            {
                OpenMSApp.d=new NoteViewer("Preview Invoice - "+jComboBox1.getSelectedItem().toString(),Configuration.officialInvoiceURLPath);
                OpenMSApp.d.setVisible(true);
            }
            else if(OpenMSApp.d.isVisible()==false)
            {
                OpenMSApp.d=new NoteViewer("Preview Invoice - "+jComboBox1.getSelectedItem().toString(),Configuration.officialInvoiceURLPath);
                OpenMSApp.d.setVisible(true);    
            }
            else{
                OpenMSApp.d.setTitle("Preview Invoice - "+jComboBox1.getSelectedItem().toString());
                OpenMSApp.d.doTas(1);
                OpenMSApp.d.transferFocus();                
            }
            /*
            run.exec("explorer "+Configuration.officialReceiptPath);                
            if(jCheckBox2.isSelected()){
            run.exec("C:\\Program Files\\PrintHTML\\printhtml.exe file=\""+Configuration.officialReceiptPath+"\" ");
            if(jCheckBox1.isSelected()){
            runAgain.exec("C:\\Program Files\\PrintHTML\\printhtml.exe file=\""+Configuration.officialReceiptPath+"\" ");
            }
            }*/
            //printReceipt.setSelected(true);
        }
        catch(Exception e)
        {
            System.out.println("Error while adding edit employee ! "+e);
        }
    }
    void printDoc()
    {
        String transferState="";
        int quantity=1;
       if(jComboBox1.getSelectedItem().equals("-- Select --"))
        {
            JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),"Please Select a Order Code ","ERROR !",JOptionPane.ERROR_MESSAGE);
            return;
        }
//        javax.swing.JInternalFrame printReceipt=new PrintReceipt(String.valueOf(jComboBox1.getSelectedItem()).trim());
//        this.getDesktopPane().add(printReceipt);
//        this.getDesktopPane().moveToFront(printReceipt);
        java.lang.Runtime run=java.lang.Runtime.getRuntime();
        java.lang.Runtime runAgain=java.lang.Runtime.getRuntime();
        try
        {
            NoteWriter note=new NoteWriter();
            note.writeInvoice(jComboBox1.getSelectedItem().toString(),transferState,quantity);
            if(jCheckBox2.isSelected()){
            run.exec("explorer "+Configuration.officialInvoicePath);                
            }
            run.exec("C:\\Program Files\\PrintHTML\\printhtml.exe file=\""+Configuration.officialInvoicePath+"\" ");
            if(jCheckBox1.isSelected()){
            runAgain.exec("C:\\Program Files\\PrintHTML\\printhtml.exe file=\""+Configuration.officialInvoicePath+"\" ");
            }
            //printReceipt.setSelected(true);
        }
        catch(Exception e)
        {
            System.out.println("Error while adding edit employee ! "+e);
        }    
    }
    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
                
        /* Execute thread */
        processThread=new Thread(new Runnable() {
            public void run() {
            disableControls();
            orderCodeSelected();
            }
        });
        titleThread=new Thread(new Runnable() {
            public void run() {
                while(processThread.isAlive())setProcessingTitle(titleThread);
                enableControls();
                System.out.println("viewItemThread stopped runing.");
            }
        });
        processThread.start();
        titleThread.start();
    }//GEN-LAST:event_jComboBox1ActionPerformed
    private void orderCodeSelected()
    {
        String orderCode=jComboBox1.getSelectedItem().toString();
        resetField();

        if(orderCode.equals("-- Select --"))
        {
            resetOrderCode();
            resetTable();
        }
       else
       {
            creditByID=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "cMerchantID");
            orderByID=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "cOrderByID");
            orderDate=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "dOrderDate");
            totalAmount=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "mTotalAmount");
            accountCode=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "cAccountCode");
            transactionDate=systems.extractSQLDate(systems.getDateValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "dCreditDate"));
            transactionNumber=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "vCreditingNumber");
            transactionTypeCode=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "cTransactionTypeCode");
            refDepartmentCode=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "cReferalDepartmentCode");
            paidAmount=systems.getValue(OpenMSApp.Database_A, "Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "mPaid");
            amountInWords=systems.getValue(OpenMSApp.Database_A, "Select tAmountInWords from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "tAmountInWords");
            discount=systems.getValue(OpenMSApp.Database_A, "Select mDiscount from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'", "mDiscount");

            dbDescription=systems.getColumn(OpenMSApp.Database_A,"Select * from Invoiceordersummary where cInvoiceOrderCode= '"+orderCode+"'",3);
            dbAmount=systems.getColumn(OpenMSApp.Database_A,"Select * from Invoiceordersummary where cInvoiceOrderCode='"+orderCode+"'",4);
            dbSerial=systems.getColumn(OpenMSApp.Database_A,"Select * from Invoiceordersummary where cInvoiceOrderCode='"+orderCode+"'",5);
            dbItem=systems.getColumn(OpenMSApp.Database_A,"Select * from Invoiceordersummary where cInvoiceOrderCode='"+orderCode+"'",2);


            creditBy=systems.getValue(OpenMSApp.Database_A,"Select * from vwMerchant where cMerchantID='"+creditByID+"'","vName");
            accountName=systems.getValue(OpenMSApp.Database_A,"Select * from Account where cAccountCode='"+accountCode+"'","vAccountName");
            accountUnit=systems.getValue(OpenMSApp.Database_A,"Select * from Account where cAccountCode='"+accountCode+"'","vAccountUnit");
            transactionType=systems.getValue(OpenMSApp.Database_A,"Select * from TransactionType where cTransactionTypeCode='"+transactionTypeCode+"'","vTransactionType");
            String OrderEmployeeID=systems.getValue(OpenMSApp.Database_A,"Select * from login where cLoginCode= '"+orderByID+"'","cEmployeeID");

            orderBy=systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID='"+OrderEmployeeID+"'","vFirstName").trim()+" "+
                    systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID='"+OrderEmployeeID+"'","vMiddleName").trim()+" "+
                    systems.getValue(OpenMSApp.Database_A,"Select * from Employee where cEmployeeID='"+OrderEmployeeID+"'","vlastName").trim();

            orderDate=systems.getValue(OpenMSApp.Database_A,"Select * from InvoiceOrder where cInvoiceOrderCode='"+orderCode+"'","dOrderDate");
            String refDepartment=systems.getValue(OpenMSApp.Database_A,"Select * from department where cDepartmentCode='"+refDepartmentCode+"'","vDepartmentName");

            jNameTextField.setText(creditBy.trim());
            jTransactionTypeTextField.setText(transactionType.trim());
            jTransactionNumberTextField.setText(transactionNumber.trim());
            jTransactionUnitTextField.setText(accountUnit.trim());
            jTransactionDateTextField.setText(transactionDate.trim());
            jAmountInWordsTextArea.setText(amountInWords.trim());
            try
            {
            jPaidTextField.setText(systems.converToRealMoneyFormat(paidAmount.trim()));
            }
            catch(Exception e)
            {
                jPaidTextField.setText("Er!M1C01K0");
            }
            try
            {
            jDiscountTextField.setText(systems.converToRealMoneyFormat(discount.trim()));
            }
            catch(Exception e)
            {
                jPaidTextField.setText("Er!M1C01K0");
            }
            try
            {
            jNetAmtTextField.setText(systems.converToRealMoneyFormat(systems.getValue(OpenMSApp.Database_A, Connect.procInit+"  prnSubtractMoney"+Connect.procInitStart+""+totalAmount.trim()+" , "+discount.trim()+Connect.procInitEnd, "mSumValue")));
            }
            catch(Exception e)
            {
                jNetAmtTextField.setText("Er!M1C01K0");
            }
            try
            {
                jTotAmountTextField.setText(systems.converToRealMoneyFormat(totalAmount.trim()));
            }
            catch(Exception e)
            {
                jTotAmountTextField.setText("Er!M1C01K0");
            }
            jAccountNameTextField.setText(accountName.trim());
            jOrderDateTextField.setText(orderDate.trim());
            jRefDepartmentTextField.setText(refDepartment.trim());
            refreshTable();
            setTitle("::. View Invoice Order - Order By User ("+orderBy+")");
            OpenMSApp.PrintInvoiceOrderCode=orderCode;
        }
    }
    private void jRefDepartmentTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRefDepartmentTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRefDepartmentTextFieldActionPerformed

    private void jTransactionTypeTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTransactionTypeTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTransactionTypeTextFieldActionPerformed

    private void jTransactionNumberTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTransactionNumberTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTransactionNumberTextFieldActionPerformed

    private void jTransactionDateTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTransactionDateTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTransactionDateTextFieldActionPerformed

    private void jAccountNameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jAccountNameTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jAccountNameTextFieldActionPerformed

    private void jTransactionUnitTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTransactionUnitTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTransactionUnitTextFieldActionPerformed

private void jPaidTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPaidTextFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jPaidTextFieldActionPerformed

private void jCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCancelButtonActionPerformed

        if(processThread.isAlive())
        {
            try{
                processThread.stop();
                titleThread.stop();
                System.out.println("Threads successfully stopped.");
            }catch(Exception e){System.out.println("Thread stopping error: "+e);}
            this.setTitle("::. View  Invoice Order");
            enableControls();
        }
        else
        dispose();
}//GEN-LAST:event_jCancelButtonActionPerformed

private void jNetAmtTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jNetAmtTextFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jNetAmtTextFieldActionPerformed

private void jDiscountTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jDiscountTextFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jDiscountTextFieldActionPerformed

private void jCheckBox5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox5ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox5ActionPerformed

private void jCheckBox6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox6ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jCheckBox6ActionPerformed

    void print()
    {
        try
        {
            jTable1.print();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    void resetOrderCode()
    {
        String[] orderCode=systems.getTableDataArray(OpenMSApp.Database_A,"invoiceOrder",1);
        orderCode[0]="-- Select --";
        jComboBox1.setModel(new DefaultComboBoxModel(orderCode));
        setTitle("::. View Invoice Order");
    }
    void resetTable()
    {
        tableObject=new Object[][]{};
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            tableObject,
            new String [] {
                "S/N", "Item","Description", "Amount"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false,false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
    }
    void resetField()
    {
        jNameTextField.setText("");
        jTotAmountTextField.setText("");
        jPaidTextField.setText("");
        jNetAmtTextField.setText("");
        jOrderDateTextField.setText("");
        jTransactionTypeTextField.setText("");
        jTransactionNumberTextField.setText("");
        jTransactionUnitTextField.setText("");
        jAccountNameTextField.setText("");
        jRefDepartmentTextField.setText("");
        jTransactionDateTextField.setText("");
        jDiscountTextField.setText("");
        jAmountInWordsTextArea.setText("");
    }
    void resetCombo()
    {
        resetOrderCode();
    }
    void reset()
    {
        resetField();
        resetTable();
        resetCombo();
    }
    private void setProcessingTitle(Thread thread)
    {
        try{
            this.setTitle("::. View  Invoice Order - Processing Request");
            thread.sleep(500);
            this.setTitle("::. View  Invoice Order - Processing Request.");
            thread.sleep(500);
            this.setTitle("::. View  Invoice Order - Processing Request..");
            thread.sleep(500);
            this.setTitle("::. View  Invoice Order - Processing Request...");
            thread.sleep(500);
        }catch(Exception e){System.out.println("Title thread"+e);}
    }
    private void disableControls()
    {
        jComboBox1.setEnabled(false);
        jPreviewButton.setEnabled(false);
    }
    private void enableControls()
    {
        jComboBox1.setEnabled(true);
        jPreviewButton.setEnabled(true);
        if(jComboBox1.getSelectedItem().toString().equalsIgnoreCase("-- Select --"))
        setTitle("::. View Invoice Order");
        else
        setTitle("::. View Invoice Order - Order By User ("+orderBy+")");
    }
    void refreshTable()
    {
        int x=0;
        int y=dbSerial.length;

        tableObject=new Object[y][4];

        while(x<y)
        {
            String itemName=systems.getValue(OpenMSApp.Database_A, "Select * from Item where cItemCode='"+dbItem[x].trim()+"'", "vName");
            
            tableObject[x][0]=dbSerial[x].trim();
            tableObject[x][1]=itemName.trim();
            tableObject[x][2]=dbDescription[x].trim();
            try
            {
                tableObject[x][3]=systems.converToRealMoneyFormat(dbAmount[x].trim());
            }
            catch(Exception e)
            {
                tableObject[x][3]="Er!M1C01K0";
            }
            systems.freeHeap();
        x+=1;
        if(x==y){break;}
       }

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            tableObject,
            new String [] {
                "S/N","Item", "Description", "Amount"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false,false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.getColumnModel().getColumn(0).setMinWidth(40);
        jTable1.getColumnModel().getColumn(0).setPreferredWidth(40);
        jTable1.getColumnModel().getColumn(0).setMaxWidth(40);
        jTable1.getColumnModel().getColumn(1).setPreferredWidth(10);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField jAccountNameTextField;
    private javax.swing.JTextArea jAmountInWordsTextArea;
    private javax.swing.JButton jCancelButton;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox5;
    private javax.swing.JCheckBox jCheckBox6;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JTextField jDiscountTextField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField jNameTextField;
    private javax.swing.JTextField jNetAmtTextField;
    private javax.swing.JTextField jOrderDateTextField;
    private javax.swing.JTextField jPaidTextField;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton jPreviewButton;
    private javax.swing.JTextField jRefDepartmentTextField;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTotAmountTextField;
    private javax.swing.JTextField jTransactionDateTextField;
    private javax.swing.JTextField jTransactionNumberTextField;
    private javax.swing.JTextField jTransactionTypeTextField;
    private javax.swing.JTextField jTransactionUnitTextField;
    // End of variables declaration//GEN-END:variables

}
